package com.bishe.demo.modules.common.controller;

import com.bishe.demo.modules.common.entity.City;
import com.bishe.demo.modules.common.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class CityController {
    @Autowired
    private CityService cityService;

    @GetMapping("/cities")
    public List<City> getCities(){
        return cityService.getCities();
    }

    @GetMapping("/cities/{pid}")
    public List<City> getCitiesByPid(@PathVariable int pid){
        return cityService.getCitiesByPid(pid);
    }
}
